Skip to content

refactor: nspikeTrain constructor takes sampleRate instead of binwidth#72

Merged
iahncajigas merged 2 commits intomainfrom
refactor/nspiketrain-samplerate-api
Mar 22, 2026
Merged

refactor: nspikeTrain constructor takes sampleRate instead of binwidth#72
iahncajigas merged 2 commits intomainfrom
refactor/nspiketrain-samplerate-api

Conversation

@iahncajigas
Copy link
Copy Markdown
Contributor

Summary

  • Change nspikeTrain.__init__ 3rd positional argument from binwidth (seconds) to sampleRate (Hz)
  • Default: 0.0011000.0 (same effective rate)
  • Fixes silent bugs where callers passed sampleRate values (10.0, 20.0) as binwidth
  • Updates all ~35 call sites across tests and tools

Test plan

  • All CI checks pass
  • pytest tests/test_nspiketrain_fidelity.py tests/test_workflow_fidelity.py tests/test_trial_fidelity.py pass locally (29 passed)
  • Smoke test: nspikeTrain([0.1, 0.3], 'n1', 1000.0, 0.0, 0.5).isSigRepBinary() returns True

🤖 Generated with Claude Code

Iahn Cajigas and others added 2 commits March 22, 2026 13:10
Change the 3rd positional argument of nspikeTrain.__init__ from
binwidth (seconds) to sampleRate (Hz), matching the user-facing
mental model. The default changes from 0.001 to 1000.0 (same
effective rate: 1/0.001 = 1000).

This fixes several silent bugs where callers passed sampleRate-like
values (10.0, 20.0) as the 3rd arg, which were misinterpreted as
binwidth (giving sampleRate=0.1 or 0.05 Hz instead of intended
10 or 20 Hz).

Changes:
- nstat/core.py: Constructor signature, nstCopy, fromStructure
- nstat/trial.py: nstColl collapsed train construction
- 8 test files: Convert explicit binwidth values to sampleRate
- 2 notebook builder tools: Convert delta to 1.0/delta

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The MATLAB gold fixtures were generated with binwidth as 3rd arg.
Values 10.0 and 2.0 in nstcoll/history tests were MATLAB binwidths
(not sampleRate), needing conversion: 10.0→0.1, 2.0→0.5.
Also convert fixture-loaded binwidth via 1.0/binwidth.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@iahncajigas iahncajigas force-pushed the refactor/nspiketrain-samplerate-api branch from bd2f676 to 16c6343 Compare March 22, 2026 17:10
@iahncajigas iahncajigas merged commit d2558c2 into main Mar 22, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant